package Lab01;

import java.util.Scanner;

public class Excise01 {
    public static void main(String[] args) {
        Employee emo = new  Employee();
        Scanner scn = new Scanner(System.in);
        System.out.println("请输入员工的信息：");
        emo.setName(scn.next());
        emo.setAge(scn.nextInt());
        emo.setGender(scn.nextBoolean());
        System.out.println(emo.toString());
    }
}
/*
*程序运行结果：
*
*     请输入员工的信息：
*     王宇航 22 true
*     员工信息:
*     姓名:王宇航 年龄:22 性别:男
* */
class Employee{
    private String name;//姓名
    private int age;//年龄
    private boolean gender;//性别    true-男性  false-女性
    //构造方法
    public Employee(String name, int age, boolean gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    public Employee() {
    }
    //getter和setter

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String isGender() {
        String str;
        if (gender){
            str = "男";
        }else {
            str = "女";
        }
        return str;
    }

    public void setGender(boolean gender) {
        this.gender = gender;
    }

    @Override
    public String toString() {
        String str;
        if (gender){
            str = "男";
        }else {
            str = "女";
        }
        return "员工信息:\n 姓名:"+name+" 年龄:"+age+" 性别:"+str;
    }
}
